package com.lin.sqltool.controller;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class AIQueryCodeController {

    @FXML
    public Button runButton;


    @FXML
    public Button deleteButton;

    @FXML
    public TextArea content;


    public void setRunButtonAction(EventHandler<ActionEvent> handler) {
        System.out.println("设置了运行逻辑");
        runButton.setOnAction(handler);
    }


    public void setDeleteButtonAction(EventHandler< ActionEvent > handler) {
        deleteButton.setOnAction(handler);
    }

    public String getTextAreaText(){
        return content.getText();
    }

    public void setTextAreaText(String text){
        content.setText(text);
    }

    @FXML
    private void handleRun(ActionEvent actionEvent){

    }

    @FXML
    public void handleDelete(ActionEvent actionEvent) {

        // 获取当前组件的父容器
        VBox parent = (VBox) deleteButton.getParent().getParent().getParent();
        // 从父容器中移除当前组件
        parent.getChildren().remove(deleteButton.getParent().getParent());

    }


}
